<!--
 * @description: 新增我的余额页面
 * @Author: latiao
 * @Date: 2021-11-08 14:03:22
 * @LastEditors: vikingShip
 * @LastEditTime: 2022-01-25 13:08:21
-->
<template>
  <view class="balance">
    <image class="balance__photo" src="https://medusa-small-file-1253272780.cos.ap-shanghai.myqcloud.com/gruul/20211108/db7f54855eb244ad9cfd74df970807df.png"></image>
    <view  class="balance__word" >我的余额</view>
    <view class="balance__num"><span class="balance__num--symbol" >￥</span><span>{{supplyBonus}}</span></view>
    <view class="balance__detail"  @click="balanceJumpHandle">余额明细</view>
    <view class="balance__button balance__button--recharge" @click="gotoRechage">充值</view>
    <view class="balance__button balance__button--withdrawal" @click="gotoWithdrawal">提现</view>
  </view>
</template>

<script lang='ts'>
  import {
    Component,
    Vue
  } from 'vue-property-decorator'
  import {
    userMsgGet
  } from "@/api/modules/user";

  @Component({})
export default class BalanceValue extends Vue {
  supplyBonus:any=0
    onLoad(){
      userMsgGet({
        infoLevel: 2
      }).then(res=>{
       this.supplyBonus=(res.infoExtends.supplyBonus+res.infoExtends.rebateBonus).toFixed(2)
      })
    }

    balanceJumpHandle() {
      const balanceDetail = "/pages/balanceDetail/balanceDetail";
      uni.navigateTo({
        url: "/subcontract" + balanceDetail
      });
    }
    gotoRechage(){
      const userInfo = this.$store.state.userStore.userInfo;
      const userMemberInfo = userInfo.infoExtends.memberInfo[0];
    // 用户会员状态 0未注册 1已注册 2会员到期
    const state = userMemberInfo.state;
     

      if(state==1){
        uni.navigateTo({
        url: "/subcontract/pages/rechage/rechage" 
      });    
      }
      else{
         uni.navigateTo({
        url: "/subcontract/pages/newRecharge/newRecharge" 
      });
        
      }   
    }
    gotoWithdrawal(){
      uni.navigateTo({
        url: "/subcontract/pages/withdrawal/withdrawal" 
      });
    }

}
</script>

<style lang="scss" scoped>
@import "@/assets/styles/balanceValue/balanceValue.scss";
</style>